package net.oschina.allchat.server.framework.im;

import net.oschina.allchat.protocol.core.JabberId;
import net.oschina.allchat.protocol.im.stanza.Presence;
import net.oschina.allchat.server.framework.core.connection.IConnectionContext;
import net.oschina.allchat.server.framework.pipe.processing.IPresenceProcessor;

public abstract class StandardPresenceProcessor implements IPresenceProcessor {

	@Override
	public boolean process(IConnectionContext context, Presence presence) {
		JabberId to = presence.getTo();
		if (to != null && !isInstantMessagingUser(to)) {
			return false;
		}
		
		return doProcess(context, presence);
	}

	protected boolean doProcess(IConnectionContext context, Presence presence) {
		// TODO Auto-generated method stub
		return false;
	}

	protected abstract boolean isInstantMessagingUser(JabberId jid);

}
